﻿using System;
using System.Reflection;

namespace YJKCodeBase.ExcelUtility.ModelLayer
{
	public class Workbooks
	{
		internal Workbooks(object thisWorkBooks)
		{
			this.workbooks = thisWorkBooks;
		}

		public Workbook Open(string path)
		{
			object thisObject;
			try
			{
				thisObject = ExcelUtilityMethod.UseMethod(this.workbooks, "Open", new object[]
				{
					path,
					false,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value,
					Missing.Value
				});
			}
			catch (Exception)
			{
				thisObject = ExcelUtilityMethod.UseMethod(this.workbooks, "Open", new object[]
				{
					path,
					false
				});
			}
			return new Workbook(thisObject);
		}

		public Workbook Add()
		{
			object thisObject = ExcelUtilityMethod.UseMethod(this.workbooks, "Add", null);
			return new Workbook(thisObject);
		}

		public void Close()
		{
			ExcelUtilityMethod.UseMethod(this.workbooks, "Close", null);
		}

		private object workbooks;
	}
}
